/* 
 * File:   WindowCreator.cpp
 * Author: clems
 * 
 * Created on May 19, 2013, 10:02 AM
 */

#include "WindowCreator.h"

WindowCreator::WindowCreator() {    
}

WindowCreator::~WindowCreator() {
}

void WindowCreator::attachDisplay(Display *d)
{
    p_display = d;
}

WMWindow *WindowCreator::create(Window w, WMScreen *screen, WMMonitor *mon)
{
    WMWindow *newWindow = new WMWindow(w, p_display);
    WindowHierarchy *hierarchy = new WindowHierarchy;
    hierarchy->screen = screen;
    hierarchy->monitor= mon;
    hierarchy->window = newWindow;
    m_windows_map[w] = hierarchy;
    return newWindow;
}


WMWindow *WindowCreator::get(Window id)
{
    WindowHierarchy *hierarchy = m_windows_map[id];
    return hierarchy->window;
}


void WindowCreator::destroy(Window window)
{
    m_windows_map.erase(window);
}